<template>
  <view>
    <view>
      <!--<nui-step :step="4"></nui-step>-->
      <nui-step :step="stepType"></nui-step>
      <text class="posi-text">
        <u-icon name="checkbox-mark" color="#42B983" size="120" class="success"></u-icon>
        <view class="info-wrapper" v-show="form && form.idCardNo">
          <view>姓名: {{form.idCardName}}</view>
          <view>身份证: {{form.idCardNo}}</view>
        </view>
        <text class="text">入职信息已提交完成，待管理员审核</text>
      </text>
    </view>
  </view>
</template>

<script>
import store from "@/store";
import {mapGetters} from 'vuex';
import AuthInfo from "@/utils/authInfo.js";

export default {
  data() {
    return {
      showModel: false,
      // 是否有骑王活动 0-是 1-否
      activity: '1',
      // 鼓励政策PDF  不为空则为存在鼓励政策PDF
      policyPdf: null,
      form: {
        idCardName: '',
        idCardNo: '',
      },
    };
  },
  computed: {
    ...mapGetters(["stepType"])
  },
  async onShow() {
    await this.getInduction()
    if (AuthInfo.getEnableTax() === true) {
      // 同步税务认证信息
      await this.syncTaxCert()
      // 查询是否需要税务认证
      await this.getNeedCert()
    }
    this.getActivitys();
    await this.getEncouragePdf()
    this.goTo()
  },
  methods: {
    getActivitys() {
      this.activity = AuthInfo.getActivity()
    },
    async getEncouragePdf() {
      const res = await this.$api.riders.getEncouragePdf();
      if (res && res.msg) {
        this.policyPdf = res.msg
      }
    },
    // 同步税务认证信息
    async syncTaxCert() {
      await this.$api.tax.syncCert()
    },
    // 查询是否需要税务认证
    async getNeedCert() {
      let res = await this.$api.tax.getNeedCert()
      this.needCert = res && res.code === 200 && res.data.need === true
      if (this.needCert === false) {
        return
      }
      // 跳转到税务认证页
      store.commit("UPDATE_ROUTEURL", "/pages/tax_verify/index");
    },
    // 页面跳转
    goTo() {
      // 存在鼓励政策,优先跳转到鼓励政策
      // 鼓励政策跳转
      if (this.policyPdf) {
        this.$store.commit("UPDATE_ENCOURAGE_PDF", this.policyPdf);
        this.$store.commit("UPDATE_HAVE_ACTIVITY", this.activity === '0');
        setTimeout(() => {
          this.$u.route("pages/agreement/index");
        }, 1200);
        return
      }
      // 不存在鼓励政策,跳转到骑王活动
      // 骑王活动跳转
      if (this.activity === '0') {
        setTimeout(() => {
          this.$u.route("pages/activity/index");
        }, 1200);
      }
    },
    async getInduction() {
      // try {
      //   this.form = {
      //     idCardName: '',
      //     idCardNo: '',
      //   }
      //   const {data} = await this.$api.riders.getInduction()
      //   this.form = {...data}
      //   if(this.form.status == '40'){
      //     let query = {
      //       inductionId : this.form.inductionId
      //     }
      //     const res = await this.$api.riders.webaccessInduction(query)
      //   }
      // } catch (e) {
      // }
    },
  },
};
</script>

<style lang="scss" scoped>
uni-page-body,
uni-view {
  height: 100%;
}

.info-wrapper {
  margin-bottom: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.posi-text {
  width: 80%;
  position: absolute;
  left: 50%;
  top: 50%;
  text-align: center;
  color: #666;
  font-size: 24px;
  transform: translate(-50%, -50%);

  .text {
    display: block;
  }
}

.success {
  margin-bottom: 20px;
}
</style>
